package com.supemarket.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.supemarket.entity.commodity;
import com.supemarket.service.Goodsservice;
import com.supemarket.service.impl.Goodsserviceimpl;
import com.supemarket.util.LayuiUtils;

public class Goodesservlet extends HttpServlet {

	private Goodsservice service = new Goodsserviceimpl();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String action =request.getParameter("action");
		if ("comm".equals(action)) {
			List<commodity> xianshi = service.comm();
			String xian =LayuiUtils.getLayuiTableJSON(xianshi);
			out.print(xian);
		}
		
		out.close();
	}

}
